package exception;

import java.util.Scanner;

class Account1 {
	int accNo;
	float amt;
	String name;
	Scanner obj = new Scanner(System.in);

	void display() {
		System.out.println("AccountNo: " + accNo);
		System.out.println("Name: " + name);
		System.out.println("Amount: " + amt);
	}

	void create() {
		try {
			System.out.print("Enter AccNo:");
			int accNo = obj.nextInt();
			System.out.print("Enter Name:");
			String name = obj.next();
			System.out.print("Enter Amount:");
			float amt = obj.nextFloat();
			if (amt < 500)
				throw new MyException1(
						"Account cant be created, Minimum Amount is 500");
			else {
				this.accNo = accNo;
				this.name = name;
				this.amt = amt;
			}
		} catch (MyException1 e) {
			System.out.println(e.toString());
			try {
				Thread.sleep(5000);
			} catch (Exception ex) {
			}
			create();
		}
	}
}

@SuppressWarnings("serial")
class MyException1 extends Exception {
	MyException1() {
	}

	MyException1(String str) {
		super(str);
	}
}

class AccTextClass {
	public static void main(String args[]) {
		Account1 myAcc = new Account1();
		myAcc.create();
		myAcc.display();
	}
}
